package cn.cyh.imeans.utils;

import com.xiaoleilu.hutool.util.StrUtil;

import java.util.List;

public class SortUtil {
    private SortUtil(){}

    /**
     * 获取固定排序的索引
     * @param sortList 固定排序的顺序
     * @param dwmc 排序字符内容
     * @return index
     */
    public static int getSortIndex(List<String> sortList, String dwmc) {
        int k = 999;
        if(StrUtil.isBlank(dwmc)) {
            return k;
        }
        for (int i = 0; i < sortList.size(); i++) {
            int i1 = dwmc.indexOf(sortList.get(i));
            if (i1 > -1) {
                return i;
            }
        }
        return k;
    }
    public static int getSortIndex1(List<String> sortList, String dwmc) {
        int k = 999;
        if(StrUtil.isBlank(dwmc)) {
            return k;
        }
        for (int i = 0; i < sortList.size(); i++) {
            if(dwmc.endsWith(sortList.get(i))) {
                return i;
            }
        }
        return k;
    }

    public static int getSortIndex2(List<String> sortList, String dwmc) {
        int k = 999;
        if(StrUtil.isBlank(dwmc)) {
            return k;
        }
        for (int i = 0; i < sortList.size(); i++) {
            if(dwmc.startsWith(sortList.get(i))) {
                return i;
            }
        }
        return k;
    }

}
